//
//  STMessageAlert.swift
//  iPhone
//
//  Created by Toj on 2/10/23.
//

import UIKit

class STMessageAlert: UIView {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupAddSubviews()
        
        messageLable.text = "This program has been added to your playlist. You will be reminded when it's updated. You can go to the playlist to turn off the reminder."
        
        defaultButton.setTitle("VIEW MY PLAYLIST", for: .normal)
        defaultButton.setTitle("OK", for: .normal)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        setupLayoutSubviews()
    }
    
    private lazy var contentView: UIView = {
        let view = UIView()
        view.backgroundColor = .white
        return view
    }()
    
    private lazy var messageLable: UILabel = {
        let view = setupLabels()
        view.numberOfLines = 0
        view.textAlignment = .center
        view.textColor = UIColor(hex: 0x666666)
        return view
    }()
    
    private func setupLabels() -> UILabel {
        let view = UILabel()
        view.autoresizesSubviews = false
        view.adjustsFontSizeToFitWidth = false
        view.lineBreakMode = .byTruncatingTail
        return view
    }
    
    private lazy var cancelButton: UIButton = {
        let view = UIButton()
        view.setTitleColor(0x0087EB.to_color, for: .normal)
        view.addTarget(self, action: #selector(didTapCancel), for: .touchUpInside)
        return view
    }()

    private lazy var defaultButton: UIButton = {
        let view = UIButton()
        view.addTarget(self, action: #selector(didTapDefault), for: .touchUpInside)
        return view
    }()
}

extension STMessageAlert {
    
    @objc private func didTapDefault() {
        
    }
    
    @objc private func didTapCancel() {
        
    }
}

extension STMessageAlert {
    
    private func setupAddSubviews() {
        addSubview(contentView)
        
        contentView.addSubview(messageLable)
        contentView.addSubview(cancelButton)
        contentView.addSubview(defaultButton)
    }
    
    private func setupLayoutSubviews() {
        messageLable.snp.makeConstraints { make in
            make.top.left.right.equalTo(self).inset(20)
        }
        
//        cancelButton.snp.makeConstraints { make in
//            make.width.equalTo(100)
//            make.height
//        }
    }
}
